<?php #coding: utf-8 æ ø å

include_once "rpg_element.php";

class Rpg_session extends Rpg_element {

	public $kampagne_id;
	public $nummer;
	public $gamemaster = array();
	public $session_tid = array();

	public function find_session($id) 
	{


        $query2 = $this->db->query
		('
            SELECT deltager.rollespiller_navn, deltager.rollespiller_efternavn, deltager.id as deltager_id, element.id
            FROM deltager, rpg_element, rpg_element_gm, element
            WHERE rpg_element_gm.id_rpg_element = "'.$id.'"
            AND rpg_element_gm.id_gm = deltager.id
            AND element.id = rpg_element.id
            AND rpg_element_gm.id_rpg_element = element.id
            AND element.slettet = 0
		');

		foreach($query2->result() as $row2)
		{
            
			$this->gamemaster[] = array(

                "id" => $row2->deltager_id,
                "navn" => $row2->rollespiller_navn,
                "efter_navn" => $row2->rollespiller_efternavn

            );
        }
        //print_r($this->gamemaster);
		
		$query = $this->db->query
		('
			SELECT session.id, navn.navn, rpg_element.id, rpg_element.offgame_start, rpg_element.offgame_slut
			FROM session, navn, rpg_element, element
			WHERE session.id = navn.id_element
			AND session.id = rpg_element.id
			AND session.id="'.$id.'"
			AND element.slettet = 0
		');

		foreach($query->result() as $row)
		{
			$this->session_tid = array
			(
				//'id' => $row->id,
				//'navn' => $row->navn,
		//		'gamemaster_id' => $row->gamemaster_id,
				'offgame_start' => $row->offgame_start,
				'offgame_slut' => $row->offgame_slut,
            
				
			);
		}
	}




}
